package org.javaboy.vhr.controller.per;

import org.javaboy.vhr.model.Employeeec;
import org.javaboy.vhr.model.RespBean;
import org.javaboy.vhr.model.RespPageBean;
import org.javaboy.vhr.service.PerEmpService;
import org.javaboy.vhr.vo.EmployeeAndWorkid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/per/perEmp")
public class PerEmpController {
    @Autowired
    PerEmpService perEmpService;
    @GetMapping("/getperEmpec")
    public RespPageBean getperEmpec(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer size){
        RespPageBean respPageBean = perEmpService.getperEmpec(page,size);
        return respPageBean;
    }
    @DeleteMapping("/{id}")
    public RespBean deleteEmpec(@PathVariable Integer id){
        if (perEmpService.deleteEmpec(id) == 1) {
            return RespBean.ok("删除成功!");
        }
        return RespBean.error("删除失败!");
    }
    @PostMapping("/")
    public RespBean addEmpec(@RequestBody Employeeec employeeec){
        if(perEmpService.addEmpec(employeeec) == 1){
            return RespBean.ok("增加成功");
        }
        return RespBean.error("增加失败");
    }
}
